<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;

class IndexController extends Controller{
    public function index(){
        $admin_user = session('admin_user');
        foreach ($admin_user as $val){
            $user_id = $val->id;
            $user_realname = $val->realname;
        }
        if($user_id == 1){
            $nav_left = DB::table('admin_group')->get();
            foreach ($nav_left as $key=>$item){

            }
            $access = DB::table('admin_node')->where('type',2)->get();
        }else{
            $nav_left = DB::table('admin_group')->get();
            $access = DB::table('admin_node')->where('type',2)->get();
        }
        return view('admin.index.index',['nav_left'=>$nav_left,'access'=>$access,'user_realname'=>$user_realname]);
    }

    public function welcome(){
        return view('admin.index.welcome');
    }
}